<?php
if(isset($form['#addr_id'])&& !empty($form['#addr_id'])) {
    echo get_template_header_info($form['#addr_id'], 'village');
}
?>
<div class="hp-tab-newprd">
    <?php if(!empty($_GET['farmer_id'])){?>
        <img style="margin-left:75px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/farmer.png"/>
    <?php }else if(!empty($_GET['addr_id'])){ ?>
        <img style="margin-left: 85px;" src="<?php echo base_path()?>sites/all/themes/tweme/images/images/village.png"/>
    <?php }?>
    <ul class="j-sw-nav">
        <?php if(!$form['#addr_id'] && !$form['#addr_id']){?>
            <li class="newprd-s1 tab-li on"><a href="<?php echo base_path(); ?>farmer/list">查看</a></li>
            <?php if(user_access('add farmer')){?>
            <li class="newprd-s2 tab-li"><a href="<?php echo base_path(); ?>farmer/add">添加</a></li>
        <?php }
        }else if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){
            echo get_tab($form['#addr_id'],'farmer','village');
            ?>

        <?php }else if(isset($form['#farmer'])&& !empty($form['#farmer'])){?>
            <li class="newprd-s1 tab-li"><a href="<?php echo base_path(); ?>village/edit/<?php echo $form['#addr_id']?>?addr_id=<?php echo $form['#addr_id']?>">基本信息</a></li>
            <li class="newprd-s3 tab-li"><a href="<?php echo base_path(); ?>village/activity/list?addr_id=<?php echo $form['#addr_id']?>">村落活动</a></li>
            <li class="newprd-s4 tab-li on"><a href="<?php echo base_path(); ?>farmer/list?addr_id=<?php echo $form['#addr_id']?>">农户列表</a></li>
        <?php }?>
    </ul>
    <div class="newprd-s1">
        <div class="table-div">
            <div style="height: 17px; cursor: pointer"><span style="float:right; margin-right: 20px; font-size: 14px;font-weight: bold" class="openORclose">展开搜索</span></div>
            <div class="search-div" style="display: none;margin-bottom: 10px">
                <?php if(empty( $form['#addr_id'])){?>

                    <?php  print _address_render_for_list($form);  ?>
                    <?php
                } ?>
                <div class="small-select max-big-input column" style="clear:both">
                    <div class="search-label">专项活动:</div><?php print render($form['special_activities']); ?>
                </div>

                <div class="small-select small-input" style="clear: both"><div class="search-label">农户姓名:</div><?php print render($form['farmername']); ?></div>
                <div class="max-select big-input column" style="clear:both">
                    <?php if( empty($_GET['distributor_id'])) { ?>
                        <div class="max-big-input address-search">
                            <div class="search-label">请选经销商:</div>
                            <?php print render($form['distributor_name']);
                            print render($form['select_distributor_button']);
                            ?>
                        </div>
                    <?php  } ?>
                </div>
                <div class="small-select small-input" style="clear: both"><div class="search-label">手机号码:</div><?php print render($form['telephone']); ?></div>
                <div class="small-select small-input" style="clear:both">
                    <div class="search-label">升级状态:</div><?php print render($form['status']); ?>
                </div>
                <div class="search-submit"><?php print render($form['submit']); ?></div>
            </div>

<!--            <img class="res-search" src='--><?php //echo base_path();?><!--sites/all/themes/tweme/images/images/stats.png'>-->
            <div class="stats-div"><span>农户信息统计结果</span></div>
            <div class="table-div">
                <div class="farmer-field" style="margin-top: 0px">
                    <div class="farmer-field-div">
                        <span>总条目:</span>
                        <span><?php echo $form['#stat']['#count']; ?>条</span>
                    </div>
                    <div class="farmer-field-div">
                        <span>平均耕地面积:</span>
                        <span><?php echo $form['#stat']['#avg_farm_area']; ?>亩</span>
                    </div>
                    <?php if(isset($form['#addr_id'])&& !empty($form['#addr_id'])){?>
                        <ul class="table-ul-li" style="float: right;">
                            <!--                        <li><a href="--><?php //echo base_path(); ?><!--farmer/list?addr_id=--><?php //echo $form['#addr_id']?><!--" class="selected">列表</a></li>-->
                            <?php if(user_access('add fertilizer_case')){?>
                                <!--                            <li>|</li>-->
                                <li><a href="<?php echo base_path(); ?>farmer/add?addr_id=<?php echo $form['#addr_id']?>" class="btn btn-primary">添加</a></li>
                            <?php } ?>
                        </ul>
                    <?php }?>
                </div>
            </div>


            <img class="res-search" src='<?php echo base_path();?>sites/all/themes/tweme/images/images/res.png'>
            <div class="table-div">
                <?php print render($form['table']); ?>
            </div>
        </div>
    </div>
</div>

<?php print drupal_render_children($form); ?>
